/**
 * 哈希表+分组
 * @param {number[]} nums1
 * @param {number[]} nums2
 * @param {number[]} nums3
 * @param {number[]} nums4
 * @return {number}
 */
var fourSumCount = function (nums1, nums2, nums3, nums4) {
    let frontTwoArrSumMap = new Map(),
        res = 0;
    for (let i = 0; i < nums1.length; i++) {
        for (let j = 0; j < nums2.length; j++) {
            frontTwoArrSumMap.set(nums1[i] + nums2[j], (frontTwoArrSumMap.get(nums1[i] + nums2[j]) || 0) + 1)
        }
    }

    for (let i = 0; i < nums1.length; i++) {
        for (let j = 0; j < nums2.length; j++) {
            if (frontTwoArrSumMap.has(-nums3[i] - nums4[j])) {
                res += frontTwoArrSumMap.get(-nums3[i] - nums4[j])
            }
        }
    }
    return res
};

console.log(fourSumCount([1, 2], [-2, -1], [-1, 2], [0, 2]));